package com.zhuiyun.pm.client.bidding.controller;


import com.zhuiyun.pm.client.bidding.mapper.ClientMyAttentionMapper;
import com.zhuiyun.pm.client.bidding.service.ClientMyAttentionService;
import com.zhuiyun.pm.result.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@RequestMapping("/myAttention")
public class ClientMyAttentionController {

    @Resource
    ClientMyAttentionMapper clientMyAttentionMapper;
    @Resource
    ClientMyAttentionService clientMyAttentionService;
    /* *
     * @Author: hui
     * @Descriprion: 全查我关注的
     * @Date: 2023/3/15 20:23
     * @return com.zhuiyun.pm.result.CommonResult
     * @param userId
     */
    @GetMapping("/findAllbyuserId")
    public CommonResult findAllbyuserId( Integer userId){
    return CommonResult.ok(clientMyAttentionMapper.findAllByUserId(userId));
    }
    /* *
     * @Author: hui
     * @Descriprion: 根据id删除
     * @Date: 2023/3/15 20:33
     * @return com.zhuiyun.pm.result.CommonResult
     * @param id
     */
    @PostMapping("/delById")
    public  CommonResult delById(@RequestParam Integer id){
//        Example example  =new Example(clientMyAttention.getClass());
//        Example.Criteria criteria = example.createCriteria();
//        criteria.andEqualTo("id",clientMyAttention.getId());
        return CommonResult.ok(clientMyAttentionMapper.del(id));
    }
    /* *
     * @Author: hui
     * @Descriprion: 查看详情（单查我关注的）
     * @Date: 2023/3/15 20:23
     * @return com.zhuiyun.pm.result.CommonResult
     * @param userId
     * @param id
     */
    @GetMapping("/selectById")
    public CommonResult selectById(@RequestParam Integer userId,@RequestParam Integer id){
        return CommonResult.ok(clientMyAttentionMapper.byid(userId,id));
    }
    /* *
     * @Author: hui
     * @Descriprion: 分页查询
     * @Date: 2023/3/16 9:20
     * @return com.zhuiyun.pm.result.CommonResult
     * @param page
     * @param size
     * @param userId
     */
    @GetMapping("/page")
    public CommonResult page(@RequestParam Integer page,@RequestParam Integer size,@RequestParam Integer userId){
        return CommonResult.ok(clientMyAttentionService.page(page,size,userId));
    }
}
